<template>
<view class="x-upload">
  <h3>上传</h3>
  <x-upload :fileList.sync="fileList"
            :maxCount="10"
            :width="160"
            :height="160"
            action="/api/core/uploadFileMinIO.do"
            maxSize="1048576000"
            :limitType="['jpg', 'png', 'pdf', 'doc', 'docx', 'ppt', 'pptx', 'zip', 'text', 'xls', 'xlsx']"
            :beforeUpload="beforeUpload"
            @success="handleSuccess"
            @error="handleError"
            @remove="handleRemove"></x-upload>
  <h3>只能预览</h3>
  <x-upload :fileList.sync="fileList"
			:maxCount="fileList.length"
      :deletable="false"
			:width="160"
			:height="160"
			action="/api/core/uploadFileMinIO.do"
			maxSize="1048576000"
			:limitType="['jpg', 'png', 'pdf', 'doc', 'docx', 'ppt', 'pptx', 'zip', 'text', 'xls', 'xlsx']"
			:beforeUpload="beforeUpload"
			@success="handleSuccess"
			@error="handleError"
			@remove="handleRemove"></x-upload>
  </view>
</template>

<script>
import XUpload from '../uni_modules/x-upload/components/x-upload'
import XPdf from '../uni_modules/x-pdf/components/x-pdf'
export default {
  components:{XUpload},
  data() {
    return {
      value: 'week',
      visible: true,
      fileList: [
        {
          filePath: 'https://oss.newpearl.com/newpearl/img/2022-03-08/e75154abb096472f8882563f268b342e.png'
        },
        {
          filePath: 'https://oss.newpearl.com/newpearl/file/2022-04-18/80e7ec783be14b489fcfcafd9fe3b580.PDF'
        }
      ]
    };
  },
  methods: {
    beforeUpload() {
      uni.showLoading({
        title: '上传中...'
      });
    },
    handleSuccess(data, index) {
      uni.hideLoading();
      this.fileList.push(data)
    },
    handleError() {
      uni.hideLoading()
    },
    handleRemove(index) {
      this.fileList.splice(index, 1);
    }
  }
};
</script>

<style>
	/* 如果使用position: fixed需要在app.vue文件加入一下样式 */
	/* iframe{
	  width: 100% !important;
	  position: fixed !important;
	  z-index: 999999 !important;
	  top: 6% !important;
	  left: 0 !important;
	  height: 94% !important;
	}

	.x-pdf uni-modal{
	  z-index: 19999 !important;
	}

	.x-pdf .u-close{
	  line-height: 1;
	} */
</style>
